<template>
  <el-dialog :visible.sync="visible" v-dialogDrag :title="title" :close-on-click-modal="false" class="tl-dialog" width="900px" @open="open" @close="close" :append-to-body="true" :modal-append-to-body="true">
    <el-form class="tl-form" ref="form" :model="model" :rules="rules" label-width="100px" :disabled="disableEditSubmit">
      <el-row>
        <el-col :span="12" v-if="!isAdd">
          <el-form-item label="行号" prop="lineno" :rules="rules.validateRequire">
            <el-input-number v-model="model.lineno" controls-position="right" :step="1" :min="0" style="width:100%" class="normal" disabled></el-input-number>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="费用类别" prop="costtype" :rules="rules.validateRequire">
            <el-select v-model="model.costtype" filterable clearable>
              <el-option v-for="item in codeModel.costtypeList" :key="item.code" :label="item.name" :value="item.code" />
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="添加日期" prop="adddate" :rules="rules.validateRequire">
            <el-date-picker v-model="model.adddate" type="date" placeholder="添加时间" value-format="yyyy-MM-dd"></el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="预算金额" prop="budgetmoney" :rules="rules.validateRequire">
            <el-input-number v-model="model.budgetmoney" controls-position="right" :step="1" :precision="2" style="width:94%"> </el-input-number>
            <span>元</span>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-alert title="提示：若本次金额为负值，则项目预算总金额会减去相应值。" type="warning" :closable="false"> </el-alert>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="预算说明" prop="note" :rules="rules.validateRequire">
            <el-input v-model="model.note" type="textarea" :rows="2"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="备注" prop="description">
            <el-input v-model="model.description" type="textarea" :rows="2"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="状态" prop="state">
            <el-input v-model="model.dispstate" disabled></el-input>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button :type="disableEditSubmit === false ? 'text' : 'primary'" @click="doCancelEdit">取消</el-button>
      <el-button type="primary" @click="doSubmitEdit" :loading="saveLoading" v-if="disableEditSubmit === false"> <svg-icon icon-class="save" />保存</el-button>
    </div>
  </el-dialog>
</template>

<script>
/** mixins */
import { mixin_edit } from "@tapui/mixins/mixin_edit"
/** 子组件 */
/** 工具类 */
import { putAction, getAction, postAction, deleteAction } from "@tapui/utils/http"
/** VUE配置 */
export default {
  mixins: [mixin_edit],
  components: {},
  data() {
    return {
      moduleTitle: "项目预算明细",
      urlPrefix: "/pm/budgetLine/",
      url: {
        // 额外的url
      }
    }
  },
  props: {
    parentId: {
      type: [Number, String],
      default: ""
    },
    projectid: {
      type: [Number, String],
      default: ""
    }
  },
  methods: {
    loaded() {
      // 页面加载完毕执行
      if (this.isAdd) {
        this.$set(this.model, "projectid", this.projectid)
        this.$set(this.model, "budgetapplyid", this.parentId)
      }
    }
  }
}
</script>
